#ifndef _STMFCT_H_
#define _STMFCT_H_

#include <stm32f10x.h>

#define bool uint8_t
#define true 1
#define false 0
#define NULL 0

#define BIT(x) ((uint32_t)((uint32_t)0x01U << (x)))
#define BITS(start, end) ((0xFFFFFFFFUL << (start)) & (0xFFFFFFFFUL >> (31U - (uint32_t)(end))))
#define IS_BIT_1(reg, bit1s) (((uint32_t)reg & (uint32_t)bit1s) == (uint32_t)bit1s)
#define IS_BIT_0(reg, bit0s) (((uint32_t)reg | (~(uint32_t)bit0s)) == (~(uint32_t)bit0s))

#define ROUND_TO_INT16(x) ((int16_t)(x) + 0.5) > (x) ? ((int16_t)(x)) : ((int16_t)(x) + 1)

bool sign8(uint8_t a);
bool sign16(uint16_t a);
bool sign32(uint32_t a);
uint8_t abs8(uint8_t a);
uint16_t abs16(uint16_t a);
uint32_t abs32(uint32_t a);
void Delay_us(uint32_t us);
void Delay_ms(uint32_t ms);
void Delay_s(uint32_t s);

#endif
